package es.ats.codington.festival.junit;


import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.domain.Stadium;
import es.ats.codington.festival.services.EventService;
import junit.framework.TestCase;

public class TestEventService extends TestCase {
	
	Event event;
	EventService es;
	int affectedRows;
	ArrayList<Event> eventList;
	int size;
	int id;
	
	@Before
	protected void setUp() throws Exception {
		super.setUp();
		event = new Event("futbol","larala",3,"sport",10,100,"lola");
		es = new EventService();
		eventList = new ArrayList<Event>();	
		size=2;
		id=2;
	}
	
	@After
	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	/*
	@Test
	public void testShowStadium() {
		Stadium stadium=new Stadium();
		stadium.setPlaceName("Stadium");
		try {
			stadium=es.showStadium(stadium);
			
			System.out.println(stadium.getIdPlace());
			System.out.println(stadium.getPlaceName());
			System.out.println(stadium.getZone());
			System.out.println(stadium.getCapacity());
			System.out.println(stadium.getStadiumName());
			
		} catch (Exception e) {
			fail("No exception should be thrown");
		} 		
	}
	*/

/*
@Test
public void testEventServiceShowEvents() {
		
			try {
				eventList=es.getShowEvents();
				assertEquals(eventList.size(),size);
				
				for(int i=0;i<eventList.size();i++)
			    {
			 		Event event1 =eventList.get(i);
			    	System.out.println("Element["+i+"] is: "+event1.getEventName()+" "+event1.getDescription()+" "+event1.getDuration());
				assertEquals(es.registerNewEvent(event),affectedRows);
			    }
				
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}	
		
		}	
		
		@Test
		public void testEventServiceCheckEvent() {
			
			try {
				event.setEventName("Opera");
				assertTrue(es.checkEvent(event));
		
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}	
			
		}
	*/
		@Test
		public void testEventServiceRegisterNewEvent() {
			
			try {
				affectedRows=1;
				assertEquals(es.registerNewEvent(event),affectedRows);
		
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}	
			
		}
		/*
		@Test
		public void testEventServiceUpdateEvent() {
			
			try {
				affectedRows=1;
				event.setIdEvent(es.getIdEvent(event));
				event.setDescription("Newevent");
				assertEquals(es.updateEvent(event),affectedRows);
		
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}
			
		}
		
		@Test
		public void testEventServiceDeleteEvent() {
			
			try {
				affectedRows=1;
				event.setIdEvent(es.getIdEvent(event));
				assertEquals(es.deleteEvent(event.getIdEvent()),affectedRows);
		
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}	
			
		}
		
		@Test
		public void testEventServiceGetIdEvent() {
			
			try {
				event.setEventName("Opera");
				assertEquals(es.getIdEvent(event),id);
			} catch (Exception ex) {
				fail("No exception should be thrown");
			}	
			
		}
		*/
	}
